// pages/setFocus/setFocus.js
let axios = require("../../utils/util.js")
import {
  IMSDK,
} from '../../utils/common.js';
Page({
  data: {
    mobile: '',
    show: false,
    exchangeNum: '', //邀请码
  },
  Diotion() {
    this.setData({
      show: true
    })
  },
  confirm() {
    let params = {
      channelcode: this.data.exchangeNum
    };
    axios.axios({
      url: "/user/bindChannle",
      data: params
    }).then((res) => {
      this.setData({
        exchangeNum: "",
      });
      wx.showToast({
        title: res.data.text,
        icon: 'none',
        duration: 3000 //持续的时间
      })
    })
  },
  exchangeInput(data) {
    this.setData({
      exchangeNum: data.detail.value
    })
  },
  cancel() {
    this.setData({
      show: false,
    });
  },
  // 绑定手机号
  tobindMobile() {
    wx.navigateTo({
      url: '/pages/bindMobile/bindMobile',
    })
  },
  toagreement() {
    wx.navigateTo({
      url: '../link/link?url=' + "https://h5.xunyinjiaoyou.com/h5/#/agreement"
      // url: '../link/link?url='+"http://192.168.1.153:8080/#/agreement"
    })
  },


  toprivacy() {
    wx.navigateTo({ 
      url: '../link/link?url=' + "https://h5.xunyinjiaoyou.com/h5/#/privacy"
    //  url: '../link/link?url='+"http://192.168.1.153:8080/#/privacy"
    })
  },
  //修改密码
  toupdatePass() {
    if (this.data.mobile) {
      wx.navigateTo({
        url: '/pages/updatePass/updatePass',
      })
    } else {
      wx.showToast({
        title: "请先绑定手机号",
        icon: 'none',
        duration: 2000 //持续的时间
      })
    }
  },
  tologin() {
    wx.clearStorage()
    let tim;
    let that = this;
    tim = IMSDK(that)
    let promise = tim.logout();
    promise.then(function (imResponse) {
      console.log(" 登出成功:",imResponse.data); // 登出成功
    }).catch(function (imError) {
      console.warn('logout error:', imError);
    });
    wx.reLaunch({
      url: '/pages/login/login',
    })
  },
  toblacklist() {
    wx.navigateTo({
      url: '/pages/blacklist/blacklist',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let user_list = wx.getStorageSync('UserInformation')
    this.setData({
      mobile: user_list.mobile
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})
